﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;

namespace DemoGrid
{
    public partial class HiddenGrid : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((!Page.IsPostBack) && (Request.QueryString["PageId"] != null))
            {
                Response.Clear();
                Response.ContentType = "text/xml";

                BindGrid();

                System.IO.StringWriter stringWrite = new System.IO.StringWriter();
                System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
                grdHidEmployeeDtls.RenderControl(htmlWrite);
                Response.Write(stringWrite.ToString());
                Response.End();
            }
        }

        private void BindGrid()
        {            
            int totalRecordCount = 0;           
            int intPageRecordCount = Convert.ToInt32(Request.QueryString["PageRecordsCount"].ToString());
            EmployeeDAO objEmployeeDAO = new EmployeeDAO();
            IList<Employee> empList = objEmployeeDAO.GetEmployeeDetails(Convert.ToInt32(Request.QueryString["PageId"].ToString()), intPageRecordCount, out totalRecordCount);
            grdHidEmployeeDtls.DataSource = empList;
            grdHidEmployeeDtls.DataBind();
        }


        public override void VerifyRenderingInServerForm(Control control)
        {
        }
        

    }
}